#include <bits/stdc++.h>
// 2025/02/04
// tag: 
// Author: Zhang Muen
using namespace std;

using int64 = int64_t;

int n, h[1001], dp[1001][40001];

signed main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> h[i];
    int ans = 0;
    for (int i = 1; i <= n; i++)
        for (int j = i - 1; j; j--)
            dp[i][h[i] - h[j] + 20000] += dp[j][h[i] - h[j] + 20000] + 1, dp[i][h[i] - h[j] + 20000] %= 998244353, ans += dp[j][h[i] - h[j] + 20000] + 1, ans %= 998244353;
    cout << (ans + n) % 998244353;
            return 0;
}